<template>
  <div style="padding:0px;">
    <el-form :model="dialogForm" ref="dialogForm" :rules="rules" :label-width="formLabelWidth">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span style="line-height: 30px;">退单物管审核</span>
        </div>
        <div class="text item">
          <el-form-item label="订单号">
            <el-input v-model="dialogForm.orderNumber" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="经销商名称">
            <el-input v-model="dialogForm.dealerInfoVO.name" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="汽车车型">
            <el-input v-model="dialogForm.carBrandName" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="购车总金额" class="currency">
            <el-input :value="dialogForm.totalPrice |toFixed2" auto-complete="off" disabled></el-input>
            <span class="convertCurrency">{{dialogForm.totalPrice|convertCurrency}}</span>
          </el-form-item>
          <el-form-item label="定金金额" class="currency">
            <el-input :value="dialogForm.earnest |toFixed2" auto-complete="off" disabled></el-input>
            <span class="convertCurrency">{{dialogForm.earnest|convertCurrency}}</span>
          </el-form-item>
          <el-form-item label="保证金金额" class="currency">
            <el-input :value="dialogForm.deposit |toFixed2" auto-complete="off" disabled></el-input>
            <span class="convertCurrency">{{dialogForm.deposit|convertCurrency}}</span>
          </el-form-item>

          <el-form-item label="垫资金额" class="currency">
            <el-input :value="dialogForm.paymentAmount|toFixed2" auto-complete="off" disabled></el-input>
            <span class="convertCurrency">{{dialogForm.paymentAmount|convertCurrency}}</span>
          </el-form-item>
          <el-form-item label="物流状态">
            <el-input v-model="dialogForm.logisticsCH" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="验车状态">
            <el-input v-model="dialogForm.carInspectionCH" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="保证金状态">
            <el-input v-model="dialogForm.cashDepositCH" auto-complete="off" disabled></el-input>
          </el-form-item>

        </div>
      </el-card>
      <el-card class="box-card" style="margin-top:15px;">
        <div slot="header" class="clearfix">
          <span style="line-height: 30px;">退单信息</span>
        </div>
        <div class="text item">

          <el-form-item label="退单理由">
            <el-input type="textarea" :rows=3 v-model="dialogForm.backRemark" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="风控审核备注">
            <el-input type="textarea" :rows=3 v-model="dialogForm.riskManagementReviewRemark" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="风控审核人">
            <el-input :rows=3 v-model="dialogForm.riskManagementReviewName" auto-complete="off" disabled></el-input>
          </el-form-item>
          <el-form-item label="风控审核时间">
            <el-input :rows=3 :value="getDate(dialogForm.riskManagementReviewTime)" auto-complete="off" disabled></el-input>
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card" style="margin-top:15px;">
        <div slot="header" class="clearfix">
          <span style="line-height: 30px;">物管审核信息</span>
        </div>
        <div class="text item">
          <el-form-item label="审核是否通过" prop="status">
            <el-radio-group v-model="dialogForm.status" :disabled="!dialogSendData.isAdd">
              <el-radio :label="180"> 通过 </el-radio>
              <el-radio :label="190"> 不通过 </el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="审核备注" prop="materialManagementReviewRemark">
            <el-input type="textarea" :rows=3 v-model="dialogForm.materialManagementReviewRemark" auto-complete="off" :disabled="!dialogSendData.isAdd"></el-input>
          </el-form-item>
        </div>
      </el-card>

    </el-form>
    <div style="text-align:right;margin-top:15px;">
      <el-button @click="returnBack">返 回</el-button>
      <el-button v-if="dialogSendData.isAdd" type="primary" @click="submitConfirmForm('dialogForm')">提 交</el-button>
    </div>
  </div>
</template>
<script>
  import agentHttp from '@/utils/agentHttp.js'
  import {
    require,
    prop
  } from '@/utils/rules.js'
  import {
    timestampToTime
  } from '@/utils/index.js'
  export default {
    created() {

      if (this.dialogSendData.id !== "") {
        this.selectData(); //修改      	    
      } else {}
    },
    props: ['dialogSendData', 'tableData', 'searchForm'],
    data() {
      return {
        formLabelWidth: '170px',
        //弹窗或者查看页面信息
        dialogForm: {
          qcsl: "",
          carOrder: 1,
          logisticsCompany: "",
          resource: ""
        },

        logisticsCompanyOptions: [{
          value: '1',
          label: '物流'
        }],
        //验证规则：
        rules: {
          'status': [require('请选择选择确认与否', {
            trigger: "change",
            type: "number"
          })],
          'materialManagementReviewRemark': [require('请填写备注信息')]

        },
      }
    },
    methods: {
      returnBack() {
        this.dialogSendData.dialogFormVisible = false;
      },
      submitConfirmForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            if (this.dialogSendData.id === "") {
              //添加
            } else {
              this.editData(); //修改
            }

          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      editData() {
        agentHttp.postJson('adminApi/admin/car_order_back/wuguan_list/audit', this.dialogForm).then((data) => {
          if (data.success) {
            this.$emit('refreshSeachData', this.searchForm);
            this.$message.success(data.data || "修改成功");
            setTimeout(() => {
              this.dialogSendData.dialogFormVisible = false;
            }, 500)
          }
        })
      },
      selectData() {
        agentHttp.get('adminApi/admin/car_order_back/wuguan_list/select/' + this.dialogSendData.id).then((data) => {
          if (data.success) {
            this.dialogForm = data.data;
            this.dialogForm.status = 180;

          }
        })
			},
			getDate(time){
				return timestampToTime(time)
			}

    }
  };
</script>